import { VNode, CreateElement } from "vue";
import _Vue from 'vue';
import { notice, message } from "./notice"
import { NoticeConfig, NoticeGlobalConfig, Noticeinfo } from "./notice/noticeConfig"
import { ModalConfig } from "./modal/modalConfig"
import Modal, { confrimModal } from "./modal"
import Icon from "./icon";
import Button from "./button"
import Input from "./input"
import Checkbox from "./checkbox"
import Form from "./form"
import Tooltip from "./tooltip"
import { Row, Col } from "./grid"

import { menu, submenu, menuitem, menugroup } from "./menu"
import { Breadcrumb, BreadCrumbItem } from "./breadcrumb"
import Affix from "./affix"
import Alert from "./alert"
import Badge from './badge';
import { Dropdown, DropdownItem, DropdownMenu } from "./dropdown"
import Poptip from './poptip';

 

declare module 'vue/types/vue' {
  interface Vue {
    $IVIEW: ViewGlobalOptions;
    $Notice: NoticeInstance;
    $Message: MessageInstance;
    $Modal: ModalInstance;
  }
}

export function AxiosPlugin(Vue: typeof _Vue, options?: ViewGlobalOptions): void {
  Vue.component("Icon", Icon);
  Vue.component("Button", Button);
  Vue.component("Input", Input);
  Vue.component("Checkbox", Checkbox.Checkbox);
  Vue.component("CheckboxGroup", Checkbox.CheckboxGroup);
  Vue.component("Form", Form.Form);
  Vue.component("FormItem", Form.FormItem);
  Vue.component("Tooltip", Tooltip);
  Vue.component("Row", Row);
  Vue.component("iCol", Col);
  Vue.component("Modal", Modal);
  Vue.component("Breadcrumb", Breadcrumb);
  Vue.component("BreadcrumbItem", BreadCrumbItem);
  Vue.component("Menu", menu);
  Vue.component("Submenu", submenu);
  Vue.component("MenuItem", menuitem);
  Vue.component("MenuGroup", menugroup);
  Vue.component("Affix", Affix);
  Vue.component("Alert", Alert);
  Vue.component("Badge", Badge);
  Vue.component("Dropdown", Dropdown);
  Vue.component("DropdownItem", DropdownItem);
  Vue.component("DropdownMenu", DropdownMenu);
  Vue.component("Poptip", Poptip);


  Vue.prototype.$Notice = notice;
  Vue.prototype.$Message = message;
  Vue.prototype.$IVIEW = options;
  Vue.prototype.$Modal = confrimModal;
}

interface ViewGlobalOptions {
  size: "default";
  transfer?: boolean | string;
  capture: false;
  select: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
  };
  cell: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
  };
  menu: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
  };
  tree: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
  };
  cascader: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
    itemArrow: string;
    customItemArrow: string;
    itemArrowSize: number | string;
  };
  colorPicker: {
    arrow: string;
    customArrow: string;
    arrowSize: number | string;
  };
  datePicker: {
    icon: string;
    customIcon: string;
    iconSize: number | string;
  };
  timePicker: {
    icon: string;
    customIcon: string;
    iconSize: number | string;
  };
  tabs: {
    closeIcon: string;
    customCloseIcon: string;
    closeIconSize: number | string;
  };
  modal: {
    maskClosable: boolean | string;
  };
}

/* interface IViewInstallOptions extends IViewGlobalOptions {
  locale?: any;
  i18n?: any;
} */

interface NoticeInstance {
  /**
   * 打开
   * @param config NoticeConfig为相关配置,string为待显示的内容
   */
  open(config?: NoticeConfig | string): void;
  /**
   * 信息
   * @param config NoticeConfig为相关配置,string为待显示的内容
   */
  info(config?: NoticeConfig | string): void;
  /**
   * 成功
   * @param config NoticeConfig为相关配置,string为待显示的内容
   */
  success(config?: NoticeConfig | string): void;
  /**
   * 警告
   * @param config NoticeConfig为相关配置,string为待显示的内容
   */
  warning(config?: NoticeConfig | string): void;
  /**
   * 错误
   * @param config NoticeConfig为相关配置,string为待显示的内容
   */
  error(config?: NoticeConfig): void;
  /**
   * 全局配置
   */
  config(options?: NoticeGlobalConfig): void;
  /**
   * 全局关闭某个通知
   */
  close(name?: string): void;
  /**
   * 全局销毁
   */
  destroy(): void;
}

export interface MessageInstance {
  /**
   * 消息
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  info(config?: Noticeinfo | string): void;
  /**
   * 成功
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  success(config?: Noticeinfo | string): void;
  /**
   * 警告
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  warning(config?: Noticeinfo | string): void;
  /**
   * 错误
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  error(config?: Noticeinfo | string): void;
  /**
   * 配置
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  loading(options?: Noticeinfo | string): void;
  /**
   * 配置
   * @param config MessageConfig为相关配置,string为待显示的内容
   */
  config(options?: NoticeGlobalConfig): void;
  /**
   * 销毁
   */
  destroy(): void;
}

export interface ModalInstance {
  /**
   * 消息
   * @param config ModalConfig为相关配置,string为待显示的内容
   */
  info(config?: ModalConfig | string): void;
  /**
   * 成功
   * @param config ModalConfig为相关配置,string为待显示的内容
   */
  success(config?: ModalConfig | string): void;
  /**
   * 警告
   * @param config ModalConfig为相关配置,string为待显示的内容
   */
  warning(config?: ModalConfig | string): void;
  /**
   * 错误
   * @param config ModalConfig为相关配置,string为待显示的内容
   */
  error(config?: ModalConfig | string): void;
  /**
   * 对话框
   * @param config ModalConfig为相关配置,string为待显示的内容
   */
  confirm(config?: ModalConfig | string): void;
  /**
   * 移除
   */
  remove(): void;
}